<template>
	<view class="">
		<tn-nav-bar :isBack='true' :backTitle='" "' bottomShadow :alpha="alpha">订单详情
		</tn-nav-bar>

		<image src="/static/product/topbg.png" class="topbg" mode=""></image>
		<loading v-if="loading"></loading>
		<view :style="{paddingTop:'calc('+vuex_custom_bar_height+'px + 30rpx)'}" class="con" v-else>
			<view class="">
				<view class="addrbox flex" v-if="proinfo.address">
					<view class="addrbox_left flex">
						<image class="addr_icon" src="static/dingwei.png" mode=""></image>
						<view class="left_right">
							<view class="addr_name">
								{{proinfo.address.province+proinfo.address.city+proinfo.address.area+proinfo.address.detail}}
							</view>
							<view class="contacts">
								{{proinfo.address.username}} <text
									style="color: #7F7F7F;margin-left: 16rpx;">{{proinfo.address.mobile}}</text>
							</view>
						</view>
					</view>
					<image class="right_icon" src="/static/img/my/right.png" mode=""></image>
				</view>
				<view class="infobox">
					<view class="proinfo flex">
						<image class="propic" :src="proinfo.imgs?URL(proinfo.imgs[0]):'/static/logo.png'"
							mode="aspectFill"></image>
						<view class="inforight">
							<view class="proname">
								{{proinfo.name}}
							</view>
							<!-- <view class="infolb flex">
								<view class="price flex">
									<text v-if="proinfo.method==0||proinfo.method==1||proinfo.method==2" style="font-size: 28rpx;color: #FF4E31;font-weight: bold;">￥</text>
									<image v-if="proinfo.method==4	" style="width: 22rpx;height: 22rpx;" src="/static/img/proitem/jf.png"
										mode=""></image>
									<image v-if="proinfo.method==3" style="width: 22rpx;height: 22rpx;" src="/static/img/proitem/tz.png"
										mode=""></image>
									<text style="font-size: 36rpx;color: #FF4E31;font-weight: bold;">{{specprice}}</text>
								</view>
							</view> -->
							<view class="ggbox">
								数量×1
								<text style="margin-left: 26rpx;" v-if="!proinfo.ems_sn&&proinfo.status<=2&&proinfo.ems_type==1">
									待发货
								</text>
								<view style="margin-left: 26rpx;display: flex;align-items: center;" v-if="(proinfo.ems_sn&&proinfo.status==2)||proinfo.ems_type==2">
									已发货
									<view class="" style="width: 40rpx;">
										
									</view>
									<tn-button v-if="proinfo.ems_type==1" fontColor="#FFFFFF" shape='round' width='158rpx' height='64rpx' :fontSize='25' backgroundColor="tn-bg-lv2" @click="to('/pages/achievement/wuliu?id='+proinfo.id)">查看物流</tn-button>
									<!-- <text style="margin: 0 20rpx;" @click="to('/pages/achievement/wuliu?id='+proinfo.id)">物流信息</text> -->
								</view>
								<text style="margin-left: 26rpx;" v-if="proinfo.status==3">
									已完成
								</text>
							</view>

						</view>
					</view>
				</view>
				<view class="conbox">
					<view class="conitem">
						<view class="left">
							订单编号
						</view>
						<view class="right">
							{{proinfo.order_sn}}
						</view>
					</view>
					<!-- <view class="conitem">
						<view class="left">
							支付方式
						</view>
						<view class="right" v-if="proinfo.method==0">
							支付宝
						</view>
						<view class="right" v-if="proinfo.method==1">
							微信
						</view>
						<view class="right" v-if="proinfo.method==2">
							惠积分
						</view>
						<view class="right" v-if="proinfo.method==3">
							惠值积分
						</view>
						<view class="right" v-if="proinfo.method==4">
							贡献值
						</view>
					</view> -->
					<view class="conitem">
						<view class="left">
							价格合计
						</view>
						<view class="right">
							<text v-if="proinfo.method==0||proinfo.method==1||proinfo.method==2">￥</text>
							{{proinfo.price ||2}}
						</view>
					</view>
					<view class="conitem">
						<view class="left">
							下单时间
						</view>
						<view class="right">
							{{timeFormat(proinfo.createtime, 'yyyy-mm-dd hh:MM')}}
						</view>
					</view>
					<view class="" v-if="proinfo.ems_type==1&&proinfo.ems_sn">
						<view class="conitem">
							<view class="left">
								物流公司
							</view>
							<view class="right">
								{{proinfo.ems||''}}
							</view>
						</view>
						<view class="conitem">
							<view class="left">
								快递单号
							</view>
							<view class="right">
								{{proinfo.ems_sn||''}}
							</view>
						</view>
					</view>
					<view class="" v-if='proinfo.ems_type==2'>
						<view class="conitem">
							<view class="left">
								物流公司
							</view>
							<view class="right">
								自提
							</view>
						</view>
					</view>
					<!-- <view class="conitem">
						<view class="left">
							发货时间
						</view>
						<view class="right">
							{{proinfo.sendtime||''}}
						</view>
					</view> -->
				</view>
			</view>
			<view class="footer">
				<!-- <tn-button fontColor="#fff" v-if="proinfo.ems_sn" shape='round' :fontSize='30' width='690rpx' backgroundColor='#E4C883'
					height='90rpx'>确认收货</tn-button> -->
				<tn-button fontColor="#fff" v-if='(proinfo.status == 2 && proinfo.ems_sn)||proinfo.ems_type==2 ' shape='round' :fontSize='30'
					width='690rpx' backgroundColor='#E4C883' height='90rpx' @click="finish">确认完成</tn-button>
			</view>
		</view>
	</view>

</template>

<script>
	import home from '@/api/_home.js'
	export default {
		data() {
			return {
				proinfo: {},
				alpha: true,
				loading:true,
				id:''
			};
		},
		methods: {
			finish() {
				let _this=this
				uni.showModal({
					title:'是否确认完成？',
					success(r) {
						if(r.confirm){
							home.finishOrder({
								id: _this.proinfo.id
							}).then(res => {
								if (res.data.code == 1) {
									uni.showToast({
										icon:'none',
										title:'已完成'
									})
									_this.getdata()
								}
							})
						}
					}
				})
			},
			getdata(){
				home.getOrder({
					id: this.id
				}).then(res => {
					this.proinfo = res.data.data
					this.proinfo.imgs = this.proinfo.image.split(',').filter(Boolean)
					this.loading=false
					// console.log(this.proinfo)
				})
			}
		},
		onLoad(option) {
			this.id=option.id
			this.getdata()
		},
		onShow() {

		}
	}
</script>

<style lang="less">
	page {
		background-color: #F7F7F9;
	}

	.con {
		padding: 22rpx 28rpx;
		position: relative;
	}

	.addrbox {
		background-color: #fff;
		padding: 31rpx 25rpx;
		justify-content: space-between;

		border-radius: 26rpx;

		.addrbox_left {

			.addr_icon {
				width: 36rpx;
				height: 41rpx;
				margin-right: 14rpx;
			}

			.left_right {

				.addr_name {
					color: #232323;
					font-size: 32rpx;
					font-weight: bold;
				}

				.contacts {
					margin-top: 4rpx;
					color: #707070;
					font-size: 26rpx;
				}
			}

		}

		.right_icon {
			width: 15rpx;
			height: 24rpx;
		}
	}

	.infobox {
		padding: 36rpx 52rpx 39rpx 22rpx;
		border-radius: 26rpx;
		background-color: #fff;
		margin-top: 25rpx;

		.dianp {
			font-size: 24rpx;
			color: #616161;

			.dpicon {
				width: 28rpx;
				height: 26rpx;
				margin-right: 10rpx;
			}

			.dpright {
				width: 12rpx;
				height: 20rpx;
				margin-left: 8rpx;
			}
		}
	}

	.proinfo {
		// margin-top: 38rpx;

		.propic {
			width: 140rpx;
			height: 140rpx;
			border-radius: 20rpx;
			margin-right: 24rpx;
		}

		.inforight {
			height: 140rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			flex: 1;

			.proname {
				font-size: 32rpx;
				color: #333333;
				font-weight: bold;
			}

			.ggbox {
				color: #6A6A6A;
				font-size: 24rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
			}

			.infolb {
				justify-content: space-between;
			}
		}
	}

	.conbox {
		background: #FFFFFF;
		border-radius: 25rpx;
		padding: 7rpx 31rpx 0;
		margin-top: 23rpx;

		.conitem {
			display: flex;
			align-items: center;
			justify-content: space-between;
			color: #707070;
			font-size: 28rpx;
			border-bottom: 1rpx solid #F1F1F1;
			padding: 36rpx 0;
		}
	}

	.flex {
		display: flex;
		align-items: center;
	}

	.u-number-box {
		border-radius: 10rpx;

		border: 1rpx solid #DFDFDF;
	}

	.minus {
		width: 51rpx;
		height: 46rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-right: 1rpx solid #DFDFDF;

		.jian {
			width: 14rpx;
			height: 2rpx;
		}
	}

	.plus {
		width: 51rpx;
		height: 46rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-left: 1rpx solid #DFDFDF;

		.jia {
			width: 16rpx;
			height: 16rpx;
		}
	}

	.footer {
		margin-top: 60rpx;
	}
</style>